package androidx.transition;

import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import androidx.annotation.NonNull;
import o.mx;
import o.nn.c;
import o.nw;
import o.nx;

public class Explode extends Visibility {
    private static final TimeInterpolator ʻ = new AccelerateInterpolator();
    private static final TimeInterpolator ˋ = new DecelerateInterpolator();
    private int[] ᐝ;

    public Explode() {
        this.ᐝ = new int[2];
        ˊ(new mx());
    }

    public Explode(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ᐝ = new int[2];
        ˊ(new mx());
    }

    private void ˎ(nx nxVar) {
        View view = nxVar.ॱ;
        view.getLocationOnScreen(this.ᐝ);
        int i = this.ᐝ[0];
        int i2 = this.ᐝ[1];
        nxVar.ˊ.put("android:explode:screenBounds", new Rect(i, i2, view.getWidth() + i, view.getHeight() + i2));
    }

    public void ˋ(@NonNull nx nxVar) {
        super.ˋ(nxVar);
        ˎ(nxVar);
    }

    public void ॱ(@NonNull nx nxVar) {
        super.ॱ(nxVar);
        ˎ(nxVar);
    }

    public Animator ˏ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        if (nxVar2 == null) {
            return null;
        }
        Rect rect = (Rect) nxVar2.ˊ.get("android:explode:screenBounds");
        float translationX = view.getTranslationX();
        float translationY = view.getTranslationY();
        ˊ((View) viewGroup, rect, this.ᐝ);
        return nw.ˋ(view, nxVar2, rect.left, rect.top, translationX + ((float) this.ᐝ[0]), translationY + ((float) this.ᐝ[1]), translationX, translationY, ˋ);
    }

    public Animator ˊ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        if (nxVar == null) {
            return null;
        }
        float f;
        float f2;
        Rect rect = (Rect) nxVar.ˊ.get("android:explode:screenBounds");
        int i = rect.left;
        int i2 = rect.top;
        float translationX = view.getTranslationX();
        float translationY = view.getTranslationY();
        int[] iArr = (int[]) nxVar.ॱ.getTag(c.ॱॱ);
        if (iArr != null) {
            float f3 = translationX + ((float) (iArr[0] - rect.left));
            f = ((float) (iArr[1] - rect.top)) + translationY;
            rect.offsetTo(iArr[0], iArr[1]);
            f2 = f;
            f = f3;
        } else {
            f2 = translationY;
            f = translationX;
        }
        ˊ((View) viewGroup, rect, this.ᐝ);
        return nw.ˋ(view, nxVar, i, i2, translationX, translationY, f + ((float) this.ᐝ[0]), f2 + ((float) this.ᐝ[1]), ʻ);
    }

    private void ˊ(View view, Rect rect, int[] iArr) {
        int round;
        int height;
        view.getLocationOnScreen(this.ᐝ);
        int i = this.ᐝ[0];
        int i2 = this.ᐝ[1];
        Rect ˊॱ = ˊॱ();
        if (ˊॱ == null) {
            round = Math.round(view.getTranslationX()) + ((view.getWidth() / 2) + i);
            height = ((view.getHeight() / 2) + i2) + Math.round(view.getTranslationY());
        } else {
            round = ˊॱ.centerX();
            height = ˊॱ.centerY();
        }
        float centerX = (float) (rect.centerX() - round);
        float centerY = (float) (rect.centerY() - height);
        if (centerX == 0.0f && centerY == 0.0f) {
            centerX = ((float) (Math.random() * 2.0d)) - 1.0f;
            centerY = ((float) (Math.random() * 2.0d)) - 1.0f;
        }
        float ˏ = ˏ(centerX, centerY);
        centerX /= ˏ;
        centerY /= ˏ;
        float ˊ = ˊ(view, round - i, height - i2);
        iArr[0] = Math.round(centerX * ˊ);
        iArr[1] = Math.round(ˊ * centerY);
    }

    private static float ˊ(View view, int i, int i2) {
        return ˏ((float) Math.max(i, view.getWidth() - i), (float) Math.max(i2, view.getHeight() - i2));
    }

    private static float ˏ(float f, float f2) {
        return (float) Math.sqrt((double) ((f * f) + (f2 * f2)));
    }
}
